cc.Class({
    extends: cc.Component,
    properties: {
        stack: cc.Node,
        cards: {
            visible: false,
            get() {
                return this.stack.cards
            }
        }
    },

    onLoad() {
        this.stack = this.stack.getComponent("CardStack")
    },

    registerEvent(){
        window.sock.node.on("11-13", e => {
            this.node.active = true
            let cards = e.detail.roomCardList
            for (let i = 0; i < cards.length; i++) {
                if (-1 !== cards[i]) {
                    this.stack.add(cards[i])
                } else {
                    break
                }
            }
        })

        window.sock.node.on("11-5", e => {
            this.node.active = true
        })

        window.sock.node.on("11-12", e => {
            let cardId = e.detail.card
            this.stack.add(cardId)
        })
    },

    clear() {
        this.stack.clear()
    },
})